package org.example.struct.array;

/**
 * @author liyishan
 * @date 2024/1/3 10:11
 * @apiNote
 */

public class Test00507CheckPerfectNumber {

    public static void main(String[] args) {
        boolean flag = checkPerfectNumber(28);
        System.out.println(flag);
    }

    public static boolean checkPerfectNumber(int num) {
        if(num ==1){
            return false;
        }
        int sum = 1;
        for(int i = 2; i * i <= num; i++){
            if(num % i == 0){
                sum += i;
                if(i * i != num){
                    sum += num/i;
                }
            }
        }
        return sum == num;
    }
}
